<%-- 
    Document   : viewShrinkage
    Created on : Dec 17, 2009, 9:10:24 PM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>View shrinkage: ${product.name}</title>
    </head>
    <body>
        <table border="1">
            <tr>
                <th colspan="3">Shrinkage: ${product.name}</th>
            </tr>
            <tr>
                <th>Record date</th>
                <th>Shrinkage units</th>
                <th>Shrinkage cost/${product.unit}</th>
            </tr>
            <c:set var="totalUnits" scope="request" value="0"/>
            <c:set var="totalCost" scope="request" value="0"/>
            <c:forEach var="shrinkage" items="${product.shrinkages}">
                <c:set var="totalUnits" scope="request" value="${totalUnits+shrinkage.units}"/>
                <c:set var="totalCost" scope="request" value="${totalCost+shrinkage.units* shrinkage.cost}"/>
                <tr>
                    <td><fmt:formatDate pattern="yyyy/MM/d" value="${shrinkage.reportedDate}"/></td>
                    <td>${shrinkage.units}</td>
                    <td>${shrinkage.cost} VND</td>
                </tr>
            </c:forEach>
            <tr><th colspan="3">Total</th></tr>
            <tr><th></th><th>Unit</th><th>Cost</th></tr>
            <tr><th></th><td>${totalUnits}</td><td>${totalCost} VND</td></tr>
            <form method="post">
                <tr>
                    <th colspan="3">Recheck shrinkage</th>
                </tr>
                <tr>
                    <td colspan="2">Current number of physical items: </td>
                    <td><input type="text" name="physicalQuantity" value="${product.totalAvailable}" /></td>
                </tr>
                <tr>
                    <td colspan="3">
                        <input type="submit" name="calc" value="Calculate and record new shrinkage" /></td>
                </tr>
            </form>
        </table>
    </body>
</html>
